package com.songlanyun.modules.refillcard.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.drive.ValueObject;
import com.songlanyun.common.validator.group.AddGroup;
import com.songlanyun.common.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;

/**
 * 充值卡
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-12 10:30:59
 */
@Data
@TableName("yxt_sale_refill_card")
public class SaleRefillCardEntity extends RootEntity<Long,SaleRefillCardEntity> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     *
     */
    @TableId
    @NotNull(message = "主键不能为空", groups = {UpdateGroup.class})
    private Long id;
    /**
     * 卡名称
     */
    @NotBlank(message = "卡名称不能为空",groups = AddGroup.class)
    @Length(min = 1, max = 16, message = "卡名称在1-16个字", groups = {AddGroup.class, UpdateGroup.class})
    private String name;
    /**
     * 购买所需费用
     */
    @NotNull(message = "所需费用不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private BigDecimal money;
    /**
     * 额外的送多少
     */
    @NotNull(message = "额外不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private BigDecimal append;
    /**
     * 是否上架
     */
    @NotNull(message = "是否上架不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Range(min = 0,max = 1,message = "上架是1，下架是0")
    private Integer added;

    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @Override
    public Long getIdentity() {
        return id;
    }
}
